package java56_4;

import java.util.Scanner;

public class GetMaxMin {

	public static void main(String[] args) {
		// 输入一批数，以0结束，输出最大的和最小的
		Scanner input = new Scanner(System.in);
		System.out.println("输入一批数：");
		int num = -1;
		int max = 0, min = 0;
		for (int i = 0; num != 0; i++) {
			num = input.nextInt();
			if (i == 0) {
				max = num;
				min = num;
			}
			if (num != 0) {
				if (max < num) {
					max = num;
				}
				if (min > num) {
					min = num;
				}
			}
		}
		System.out.printf("最大的是%d,最小的是%d", max, min);
	}

}
